import axios from './axios'
import qs from 'qs'
import { appId } from '../assets/js/app'


export function getHomePage() {
    var tgid = $cookies.get('tgid')
    var token = $cookies.get('token')
    var data = { tgid: tgid, token: token }
    return axios({
        url: '/home_page',
        method: 'post',
        data: qs.stringify(data),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
    })
}

export function getGameList(i, page, client, genreid) {
    var tgid = $cookies.get('tgid')
    var token = $cookies.get('token')
    return axios({
        url: '/gamelist',
        method: 'post',
        data: qs.stringify({
            tgid: tgid,
            token: token,
            game_type: i,
            page: page,
            client_type: client,
            genre_id: genreid
        }),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

export function getSearchGame(value) {
    var tgid = $cookies.get('tgid')
    var token = $cookies.get('token')
    return axios({
        url: '/gamelist',
        method: 'post',
        data: qs.stringify({
            tgid: tgid,
            token: token,
            kw: value
        }),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

export function getSearchOther(gametype, typeid, gamename) {
    var tgid = $cookies.get('tgid')
    var token = $cookies.get('token')
    return axios({
        url: '/newslist',
        method: 'post',
        data: qs.stringify({
            tgid: tgid,
            token: token,
            game_type: gametype,
            typeid: typeid,
            gamename: gamename
        }),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

export function getServerGame(gameType, timeType, page) {
    var tgid = $cookies.get('tgid')
    var token = $cookies.get('token')
    return axios({
        url: '/serverlist',
        method: 'post',
        data: qs.stringify({
            tgid: tgid,
            token: token,
            game_type: gameType,
            time_type: timeType,
            page: page,
        }),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

export function getNoticeList() {
    var tgid = $cookies.get('tgid')
    var token = $cookies.get('token')
    var appid = appId()
    return axios({
        url: '/notice_list',
        method: 'post',
        data: qs.stringify({
            tgid: tgid,
            token: token,
            appid: appid
        }),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

//意见反馈
export function getFeedBack(radio_v, contact, content) {
    var tgid = $cookies.get('tgid')
    var token = $cookies.get('token')
    return axios({
        url: '/feedback',
        method: 'post',
        data: qs.stringify({
            tgid: tgid,
            token: token,
            radio_v: radio_v,
            contact: contact,
            content: content,
        }),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

export function getRegisterList(url, datetype, begintime, endtime, page, username, gamename) {
    var tgid = $cookies.get('tgid')
    var token = $cookies.get('token')
    return axios({
        url: url,
        method: 'post',
        data: qs.stringify({
            tgid: tgid,
            token: token,
            datetype: datetype,
            begintime: begintime,
            endtime: endtime,
            page: page,
            username: username,
            gamename: gamename,
        }),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

export function getRegisterDetail(uid) {
    var tgid = $cookies.get('tgid')
    var token = $cookies.get('token')
    return axios({
        url: '/player_info',
        method: 'post',
        data: qs.stringify({
            tgid: tgid,
            token: token,
            uid: uid,
        }),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

export function getNewsList(gametype, typeid, page) {
    var tgid = $cookies.get('tgid')
    var token = $cookies.get('token')
    return axios({
        url: '/newslist',
        method: 'post',
        data: qs.stringify({
            tgid: tgid,
            token: token,
            game_type: gametype,
            typeid: typeid,
            page: page,
        }),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

export function getToolAPI() {
    var tgid = $cookies.get('tgid')
    var token = $cookies.get('token')
    return axios({
        url: '/assist_tool',
        method: 'post',
        data: qs.stringify({
            tgid: tgid,
            token: token,
        }),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

export function getUserCashList(page) {
    var tgid = $cookies.get('tgid')
    var token = $cookies.get('token')
    return axios({
        url: '/user_cash_list',
        method: 'post',
        data: qs.stringify({
            tgid: tgid,
            token: token,
            page: page,
        }),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

export function getInviteData() { //分享
    var tgid = $cookies.get('tgid')
    var token = $cookies.get('token')
    var appid = appId()
    return axios({
        url: '/invite_data',
        method: 'post',
        data: qs.stringify({
            tgid: tgid,
            token: token,
            appid: appid,
        }),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

export function getUserBankList() { //提现信息
    var tgid = $cookies.get('tgid')
    var token = $cookies.get('token')
    return axios({
        url: '/user_bank_list',
        method: 'post',
        data: qs.stringify({
            tgid: tgid,
            token: token,
        }),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

export function getCash(amount, ub_id, cash_pwd) {
    var tgid = $cookies.get('tgid')
    var token = $cookies.get('token')
    return axios({
        url: '/get_cash',
        method: 'post',
        data: qs.stringify({
            tgid: tgid,
            token: token,
            amount: amount,
            ub_id: ub_id,
            cash_pwd: cash_pwd,
        }),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

export function getCode(phone) { // 短信验证码
    var tgid = $cookies.get('tgid')
    var token = $cookies.get('token')
    return axios({
        url: '/get_bind_bank_code',
        method: 'post',
        data: qs.stringify({
            tgid: tgid,
            token: token,
            mobile: phone,
        }),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

export function getBankList() { // 银行列表
    var tgid = $cookies.get('tgid')
    var token = $cookies.get('token')
    return axios({
        url: '/bank_list',
        method: 'post',
        data: qs.stringify({
            tgid: tgid,
            token: token,
            type: '',
        }),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

//绑定银行卡
export function getBindBank(bank_id, kaihuhang, account1, account2, realname, email, phone, code) {
    var tgid = $cookies.get('tgid')
    var token = $cookies.get('token')
    return axios({
        url: '/bind_bank',
        method: 'post',
        data: qs.stringify({
            tgid: tgid,
            token: token,
            bank_id: bank_id, //银行
            kaihuhang: kaihuhang, //开户行
            account1: account1, //账号1
            account2: account2, //账号2
            realname: realname, //真实姓名
            email: email, //邮箱
            mobile: phone, //手机号码
            verify_code: code, //验证码
        }),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

//绑定支付宝信息
export function getAliPay(account1, account2, realname, email, phone, code) {
    var tgid = $cookies.get('tgid')
    var token = $cookies.get('token')
    return axios({
        url: '/bind_bank',
        method: 'post',
        data: qs.stringify({
            tgid: tgid,
            token: token,
            account1: account1, //账号1
            account2: account2, //账号2
            realname: realname, //真实姓名
            email: email, //邮箱
            mobile: phone, //手机号码
            verify_code: code, //验证码
        }),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

//修改密码  fieldtype=3 提现    
export function getCashPwd(index_v, field1, field2, field3) {
    var tgid = $cookies.get('tgid')
    var token = $cookies.get('token')
    return axios({
        url: '/modify_pwd',
        method: 'post',
        data: qs.stringify({
            tgid: tgid,
            token: token,
            fieldtype: index_v,
            field1: field1,
            field2: field2,
            field3: field3,
        }),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

//代充余额兑换
export function getBalanceCash(amount, pwd) {
    var tgid = $cookies.get('tgid')
    var token = $cookies.get('token')
    return axios({
        url: '/changeToPtb',
        method: 'post',
        data: qs.stringify({
            tgid: tgid,
            token: token,
            amount: amount,
            pwd: pwd,
        }),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

//代充自助充值
export function getRedeemVoucher(amount, paytype, is_pc) {
    var tgid = $cookies.get('tgid')
    var token = $cookies.get('token')
    return axios({
        url: '/payPtb',
        method: 'post',
        data: qs.stringify({
            tgid: tgid,
            token: token,
            amount: amount,
            paytype: paytype,
            is_pc: is_pc,
        }),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

//代充充值平台币
export function getPtb(amount, username, pwd) {
    var tgid = $cookies.get('tgid')
    var token = $cookies.get('token')
    return axios({
        url: '/dcPtb',
        method: 'post',
        data: qs.stringify({
            tgid: tgid,
            token: token,
            amount: amount,
            username: username,
            pwd: pwd
        }),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

//代充充值记录搜索
export function getPtbList(page, username, typeid, begintime, endtime) {
    var tgid = $cookies.get('tgid')
    var token = $cookies.get('token')
    return axios({
        url: '/getPtbLogList',
        method: 'post',
        data: qs.stringify({
            tgid: tgid,
            token: token,
            page: page,
            username: username,
            typeid: typeid,
            begintime: begintime,
            endtime: endtime,
        }),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

//代充充值代金券游戏搜索
export function getGameNameQuery(gamename) {
    var tgid = $cookies.get('tgid')
    var token = $cookies.get('token')
    return axios({
        url: '/getDcGameList',
        method: 'post',
        data: qs.stringify({
            tgid: tgid,
            token: token,
            gamename: gamename,
        }),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

//代充充值代金券
export function getCoupon(amount, username, pwd, gameid) {
    var tgid = $cookies.get('tgid')
    var token = $cookies.get('token')
    return axios({
        url: '/dcPtb',
        method: 'post',
        data: qs.stringify({
            tgid: tgid,
            token: token,
            amount: amount,
            username: username,
            pwd: pwd,
            gameid: gameid,
        }),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}